<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>响应式布局-横竖屏检测</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        body{
            display: flex;
            flex-wrap: wrap;
        }
        div{
            height: 100px;
            background: yellow;
            border: 2px solid red;
            box-sizing: border-box;
        }
        /*竖屏*/
        @media screen and (orientation:portrait) {
            div{
                width: 33.33%;
            }
        }
         /*横屏*/
         @media screen and (orientation:landscape) {
            div{
                width: 25%;
            }
        }
    </style>
</head>
<body>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
</body>
</html>